import request from "../utils/request"
// 统一管理路由
// 获取轮播图
export const reqBannner = () => {
    return request({
        url: "/mall-api/index/findBanner",
        // "url": "/mall-api/index/advertisement",
    });
}
//  获取一级标题
export const reqCategory = () => {
    return request({
        url: "/mall-api/index/findCategory1"
    })
}

// 猜你喜欢
export const reqLike = () => {
    return request({
        url: '/mall-api/index/findListGoods'
    })
}

// 热门推荐
export const reqHot = () => {
    return request({
        url: '/mall-api/index/findRecommendGoods'
    })
}

// 获取分类模块的数据
export const reqSort = () => {
    return request({
        url: '/mall-api/index/findCategoryTree'
    })
}

// 获取用户授权登录成功用户的唯一表示token
export const reqToken = (code) => {
    return request({
        url: `/mall-api/weixin/wxLogin/${code}`
    })
}

// 获取用户信息
export const reqUserInfo = () => {
    return request({
        url: "/mall-api/weixin/getuserInfo"
    })
}
//更新用户信息的接口
export const reqUpdateInfo = (data) => {
    return request({
        url: `/mall-api/weixin/updateUser`,
        method: "POST",
        data: data
    })
}

// 获取商品列表的接口
export const reqGoodsList = (page, limit, category2Id) => {
    return request({
        url: `/mall-api/goods/list/${page}/${limit}?category2Id=${category2Id}`
    })
}

// 获取购物车列表
export const reqCart = () => {
    return request({
        url: "/mall-api/cart/getCartList"
    })
}

// 更新用户勾选的状态
export const reqUpdataChecked = (goodsId, isChecked) => {
    return request({
        url: `/mall-api/cart/checkCart/${goodsId}/${isChecked}`,
    })
}

// 删除商品
export const reqDeleteGood = (goodsId) => {
    return request({
        url: `/mall-api/cart/delete/${goodsId}`
    })
}


// 添加或者修改商品的数量
export const reqAddOrUpdataCart = (goodsId, count, blessing) => {
    return request({
        url: `/mall-api/cart/addToCart/${goodsId}/${count}?blessing=${blessing}`
    })
}

// 获取商品详情
export const reqGoodDetail = (goodsId) => {
    return request({
        url: `/mall-api/goods/${goodsId}`
    })
}

// 获取订单详情页面,立即购买的商品的信息
export const reqBuyNowGoodsInfo = (goodsId, remarks) => {
    return request({
        url: `/mall-api/order/buy/${goodsId}?blessing=${remarks}`
    })
}

// 获取收件人的地址信息
export const reqAdress = () => {
    return request({
        url: "/mall-api/userAddress/getOrderAddress"
    })
}



// 提交订单接口
export const reqSubmit = (data) => {
    request({
        url: `/mall-api/order/submitOrder`,
        method: "POST",
        data
    })
}

// 获取支付参数接口
export const reqPayInfo = (orderNo) => {
    return request({
        url: `/mall-api/webChat/createJsapi/${orderNo}`
    })
}


// 支付结果的查询
export const reqPayStatus = (orderNo) => {
    return request({
        url: `/mall-api/webChat/queryPayStatus/${orderNo}`
    })
}

// 添加地址
export const reqAddAddress = (data) => {
    return request({
        url: `/mall-api/userAddress/save`,
        method: "POST",
        data
    })
}
// 获取地址列表数据
export const reqAddressList = () => {
    return request({
        url: "/mall-api/userAddress/findUserAddress"
    })
}

// 获取编辑地址的详细星系
export const reqEditAddress = (id) => {
    return request({
        url: `/mall-api/userAddress/${id}`
    })
}

// 更新地址信息
export const reqUpdataAddress = (data) => {
    return request({
        url: '/mall-api/userAddress/update',
        method: "POST",
        data
    })
}

// 删除已有的用户信息
export const reqDeleteUser = (id) => {
    return request({
        url: `/mall-api/userAddress/delete/${id}`
    })
}